home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap21 / EdrTest / EdrLib.c next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.1 KB  |  40 lines

  1. /*-------------------------------------------------
  2.    EDRLIB.C -- Easy Drawing Routine Library module
  3.                (c) Charles Petzold, 1998
  4.   -------------------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include "edrlib.h"
  8.  
  9. int WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
  10. {
  11.      return TRUE ;
  12. }
  13.  
  14. EXPORT BOOL CALLBACK EdrCenterTextA (HDC hdc, PRECT prc, PCSTR pString)
  15. {
  16.      int  iLength ;
  17.      SIZE size ;
  18.  
  19.      iLength = lstrlenA (pString) ;
  20.  
  21.      GetTextExtentPoint32A (hdc, pString, iLength, &size) ;
  22.  
  23.      return TextOutA (hdc, (prc->right - prc->left - size.cx) / 2,
  24.                            (prc->bottom - prc->top - size.cy) / 2,
  25.                       pString, iLength) ;
  26. }
  27.  
  28. EXPORT BOOL CALLBACK EdrCenterTextW (HDC hdc, PRECT prc, PCWSTR pString)
  29. {
  30.      int  iLength ;
  31.      SIZE size ;
  32.  
  33.      iLength = lstrlenW (pString) ;
  34.  
  35.      GetTextExtentPoint32W (hdc, pString, iLength, &size) ;
  36.  
  37.      return TextOutW (hdc, (prc->right - prc->left - size.cx) / 2,
  38.                            (prc->bottom - prc->top - size.cy) / 2,
  39.                       pString, iLength) ;
  40. }